package com.campus.service.impl;

import com.campus.dao.TeacherDao;
import com.campus.model.Teacher;
import com.campus.model.User;
import com.campus.service.TeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class TeacherServiceImpl implements TeacherService {

    @Autowired
    private TeacherDao teacherDao;

    @Override
    public boolean addTeacher(Teacher teacher, User user) {
        return teacherDao.addTeacher(teacher,user);
    }

    @Override
    public Teacher getTeacherById(Integer id) {
        return teacherDao.getTeacherById(id);
    }

    @Override
    public List<Teacher> searchTeachers(String teacherName, String subject, String school) {
        return teacherDao.searchTeachers(teacherName, subject, school);
    }

    @Override
    public boolean editTeacher(Integer id, Teacher teacher) {
        return teacherDao.updateTeacher(id, teacher) > 0;
    }

    @Override
    public boolean deleteTeacher(Integer id) {
        return teacherDao.deleteTeacherById(id) > 0;
    }

    @Override
    public List<Teacher> getAllTeachers() {
        return teacherDao.findAllTeachers();
    }

}
